package MyGui;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * Title:        iPAD
 * Description:
 * Copyright:    Copyright (c) 2002
 * Company:      ABB Inc.
 * @author Fangxing Li
 * @version 1.0
 */

class AllCompatiableFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".mdb") ){
                return true; }
            else if (filename.toLowerCase().endsWith(".pad") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "IPAD Compatiable Format (*.mdb, *.pad)";
    }
}//end of class MdbFileFilter

class MdbFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".mdb") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "MS Access Files (*.mdb)";
    }
}//end of class MdbFileFilter

class PadFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".pad") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "PAD format files (*.pad)";
    }
}//end of class PadFileFilterter

class CsvFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".csv") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "CSV files (*.csv)";
    }
}//end of class CsvFileFilterter

// ********* Added by Yanli Wei, 04/16/2011 **********
class TxtFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".txt") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "Txt files (*.txt)";
    }
}//end of class TxtFileFilterter

class MatFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".m") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "Matlab files (*.m)";
    }
}//end of class TxtFileFilterter

/*==============================================
  All File Filters for image files
==============================================*/

class AllImageFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".gif") ){
                return true; }
            else if (filename.toLowerCase().endsWith(".jpg") ) {
                return true; }
            else if (filename.toLowerCase().endsWith(".png") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "IPAD Image Format (*.gif, *.jpg, *.png)";
    }
}//end of class AllImageFileFilter

class GifFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".gif") ){
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "IPAD Compatiable Format (*.gif)";
    }
}//end of class GifFileFilter

class JpegFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".jpg") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "IPAD Compatiable Format (*.jpg)";
    }
}//end of class JpegFileFilter

class PngFileFilter extends javax.swing.filechooser.FileFilter{
    public boolean accept(File f) {
        if (f.isDirectory()) {   return true;   }
        else {
            String filename = f.getName();
            if (filename.toLowerCase().endsWith(".png") ) {
                return true; }
            else { return false; }
        }
    }//end of accept

    public String getDescription() {
        return "IPAD Compatiable Format (*.png)";
    }
}//end of class PngFileFilter
